package com.logic.idevice.impl.kjd

import android.content.Context
import androidx.lifecycle.Lifecycle
import com.handheld.uhfr.UHFRManager
import com.logic.idevice.IUHFSetting
import com.orhanobut.hawk.Hawk
import com.sinopec.basemodule.constants.PreferencesConstant

/**
 * @author lwj
 * @ClassName: KjdSetting
 * @Description: 汉德霍尔防爆机Kjd手持设备
 */
class KjdSetting(
    val refreshPowerUi: (Int) -> Unit,
    val refreshTemUi: (String) -> Unit,
) : IUHFSetting {
    val TAG = "Kjd-" + KjdSetting::class.java.simpleName
    private var mRfidManager: UHFRManager? = null
    private var RFID_INIT_STATUS = false

    companion object {
        var pow: Int
            get() = Hawk.get("KjdSetting_pow") ?: 0
            set(value) {
                Hawk.put("KjdSetting_pow", value)
            }
    }

    override fun init(context: Context, lifecycle: Lifecycle) {
    }


    override fun openVoince(): Boolean {
        return PreferencesConstant.getInstance().beeper_model == 1
    }

    override fun save(power: Int, openVoince: Boolean) {
        //保存并设置功率
        pow = power
        //2.保存提示音状态
        PreferencesConstant.getInstance().beeper_model = if (openVoince) 1 else 0
    }

    override fun readTemperature(): String {
        return ""
    }

    override fun refreshTemperature() {
        refreshTemUi(readTemperature())
    }

    override fun readPower(): Int {
        return pow
    }

    override fun refreshPower() {
        refreshPowerUi(readPower())
    }
}